using Senparc.Weixin.HttpUtility;
using Senparc.Weixin.QY.AdvancedAPIs.Asynchronous;
using Senparc.Weixin.QY.CommonAPIs;
using System;
namespace Senparc.Weixin.QY.AdvancedAPIs
{
	public static class AsynchronousApi
	{
		public static AsynchronousJobId BatchInviteUser(string accessToken, string toUser, string toParty, string toTag, string inviteTips, Asynchronous_CallBack callBack, int timeOut = 10000)
		{
			string urlFormat = "https://qyapi.weixin.qq.com/cgi-bin/batch/inviteuser?access_token={0}";
			var data = new
			{
				touser = toUser,
				toparty = toParty,
				totag = toTag,
				invite_tips = inviteTips,
				callback = callBack
			};
			return CommonJsonSend.Send<AsynchronousJobId>(accessToken, urlFormat, data, CommonJsonSendType.POST, timeOut);
		}
		public static AsynchronousJobId BatchSyncUser(string accessToken, string mediaId, Asynchronous_CallBack callBack, int timeOut = 10000)
		{
			string urlFormat = "https://qyapi.weixin.qq.com/cgi-bin/batch/syncuser?access_token={0}";
			var data = new
			{
				media_id = mediaId,
				callback = callBack
			};
			return CommonJsonSend.Send<AsynchronousJobId>(accessToken, urlFormat, data, CommonJsonSendType.POST, timeOut);
		}
		public static AsynchronousJobId BatchReplaceUser(string accessToken, string mediaId, Asynchronous_CallBack callBack, int timeOut = 10000)
		{
			string urlFormat = "https://qyapi.weixin.qq.com/cgi-bin/batch/replaceuser?access_token={0}";
			var data = new
			{
				media_id = mediaId,
				callback = callBack
			};
			return CommonJsonSend.Send<AsynchronousJobId>(accessToken, urlFormat, data, CommonJsonSendType.POST, timeOut);
		}
		public static AsynchronousJobId BatchReplaceParty(string accessToken, string mediaId, Asynchronous_CallBack callBack, int timeOut = 10000)
		{
			string urlFormat = "https://qyapi.weixin.qq.com/cgi-bin/batch/replaceparty?access_token={0}";
			var data = new
			{
				media_id = mediaId,
				callback = callBack
			};
			return CommonJsonSend.Send<AsynchronousJobId>(accessToken, urlFormat, data, CommonJsonSendType.POST, timeOut);
		}
		public static AsynchronousInviteUserResult GetInviteUserResult(string accessToken, string jobId)
		{
			string url = string.Format("https://qyapi.weixin.qq.com/cgi-bin/batch/getresult?access_token={0}&jobid={1}", accessToken, jobId);
			return Get.GetJson<AsynchronousInviteUserResult>(url, null);
		}
		public static AsynchronousReplaceUserResult GetReplaceUserResult(string accessToken, string jobId)
		{
			string url = string.Format("https://qyapi.weixin.qq.com/cgi-bin/batch/getresult?access_token={0}&jobid={1}", accessToken, jobId);
			return Get.GetJson<AsynchronousReplaceUserResult>(url, null);
		}
		public static AsynchronousReplacePartyResult GetReplacePartyResult(string accessToken, string jobId)
		{
			string url = string.Format("https://qyapi.weixin.qq.com/cgi-bin/batch/getresult?access_token={0}&jobid={1}", accessToken, jobId);
			return Get.GetJson<AsynchronousReplacePartyResult>(url, null);
		}
	}
}
